import React, { Component, PropTypes } from 'react';

class FormElement extends Component {

  static propTtypes = {
    config: React.PropTypes.object.isRequired,
    type: React.PropTypes.string.isRequired,
    value: React.PropTypes.any
  }

  getOptionElment (type) {
    let checked = value => {return {defaultChecked: this.props.value === value}}

    let Element = (<div><label className="checkbox-inline">
          <input type="radio" name={this.props.config.name} value="1" {...checked(1)} /> 是 
        </label>
        <label className="checkbox-inline">
          <input type="radio" name={this.props.config.name} value="0" {...checked(0)} /> 否
        </label>
      </div>)

    if ('checkbox' === type) {
      Element = (<div>还未开发</div>)
    }

    return Element
  }

  render () {

    return this.getOptionElment(this.props.type)

  }

}

export default FormElement

